#ifndef MINCOSTFLOWALGORITHM_H_
#define MINCOSTFLOWALGORITHM_H_

#include "IGraphAlgorithm.h"

#include "graph_support/attributes/CostFlowEdgeAttributes.h"


namespace native_orbitor
{

class MinCostFlowAlgorithm : public IGraphAlgorithm
{
public:
	MinCostFlowAlgorithm( size_t src, size_t dest )
		: src( src )
		, dest( dest )
	{
	}

private:
	typedef GRAPH_SUPPORT_NS::impls::vector::VectorGraphTmpl<
			int,
			GRAPH_SUPPORT_NS::attributes::CostFlowEdgeAttributesTmpl< double >,
			stdext::hash< int >,
			stdext::equal_to< int >
			> Graph;

public:
	virtual bool isApplicable2graph( GRAPH_SUPPORT_NS::Graph * abstractGraphPtr )
	{
		Graph * graphPtr = dynamic_cast< Graph * >( abstractGraphPtr );
		return graphPtr != NULL;
	}

	virtual void runOnGraph( GRAPH_SUPPORT_NS::Graph * abstractGraphPtr )
	{
		using namespace GRAPH_SUPPORT_NS::alg::flow;

		Graph * graphPtr = dynamic_cast< Graph * >( abstractGraphPtr );
		assert( graphPtr );
		Graph & graph = * graphPtr;

		Dinic< Graph > dinic( graph );
		dinic( graph.num2vert( src ), graph.num2vert( dest ) );
	}

private:
	size_t src;
	size_t dest;
};

}

#endif /* MINCOSTFLOWALGORITHM_H_ */
